package com.wjbgn.weatherforecast.controller;

import com.wjbgn.weatherforecast.service.IWeatherService;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description： 天气控制器
 * @author：weirx
 * @date：2022/5/20 16:02
 * @version：3.0
 */
@Data
@RestController
@RequestMapping("/weather")
@AllArgsConstructor
public class WeatherController {

    private IWeatherService weatherService;

    @GetMapping("/importCityCode")
    @ResponseBody
    public void importCityCode(){
        weatherService.importCityCode();
    }

    @GetMapping("/getCityWeather")
    @ResponseBody
    public String getCityWeather(@RequestParam String cityCode){
       return weatherService.getCityWeather(cityCode);
    }

    @GetMapping("/getCityInfo")
    @ResponseBody
    public List getCityInfo(){
        return weatherService.getCityInfo();
    }

    @GetMapping("/getProvincialCapitalWeather")
    @ResponseBody
    public List<Map<String,Object>> getProvincialCapitalWeather(){
        return weatherService.getProvincialCapitalWeather();
    }

}
